package com.bj.disc.ui.login.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.ai3d.rfid.base.activity.BaseContainerVmActivity
import com.ai3d.rfid.base.vm.ContainerViewModel
import com.ai3d.rfid.common.libs.InitLanguage
import com.ai3d.rfid.databinding.LayoutContainerBinding
import com.bj.disc.ui.login.fragment.LoginFragment


class LoginActivity : BaseContainerVmActivity<ContainerViewModel, LayoutContainerBinding>() {
    companion object {
        fun startLoginActivity(activity: Activity, inputAccount: String? = null, inputPassWord: String? = null) {
            var intent = Intent(activity, LoginActivity::class.java)
            intent.putExtra("account", inputAccount)
            intent.putExtra("password", inputPassWord)
            activity.overridePendingTransition(0, 0)
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
            activity.finish()
            activity.overridePendingTransition(0, 0)
            activity.startActivity(intent)
        }

        //欢迎页、首页跳转登录页的方法  这个以前就是这样写的  不想深究跟上面那个方法的区别了  就用回以前的了
        fun startLoginActivity(activity: Activity){
            var intent = Intent(activity, LoginActivity::class.java)
            activity.startActivity(intent)
            activity.overridePendingTransition(0, 0)
        }
    }

    override fun initView(savedInstanceState: Bundle?) {
        changeFragment(
            LoginFragment().apply {
                arguments = Bundle().apply {
                    putString("account", intent.getStringExtra("account"))
                    putString("password", intent.getStringExtra("password"))
                }
            }
        )
    }

//    override fun getResources(): Resources {
//        var res = super.getResources()
//        try {
//            if (res != null && res.configuration.locale != InitLanguage.locale) {
//                var config = Configuration()
//                config.setLocale(InitLanguage.locale)
//                res.updateConfiguration(config, res.displayMetrics)
//                Logcat.d("tempFontStr loginActivity ")
//            }
//        } catch (e: Exception) {
//            e.printStackTrace()
//        }
//        return res
//    }

    override fun onBackPressed() {
        super.onBackPressed()
        InitLanguage.finishAll()
    }
}